/**
 * 向Scalar API Reference添加加载效果的自定义插件
 */
const fs = require('fs');
const path = require('path');

module.exports = function () {
  // 读取CSS文件内容
  const cssPath = path.join(__dirname, 'scalar-loading-styles.css');
  const cssContent = fs.readFileSync(cssPath, 'utf8');
  
  // 读取JavaScript文件内容
  const jsPath = path.join(__dirname, 'scalar-loading-script.js');
  const jsContent = fs.readFileSync(jsPath, 'utf8');

  return {
    name: 'scalar-loading-plugin',
    injectHtmlTags() {
      return {
        headTags: [
          {
            tagName: 'style',
            attributes: {
              type: 'text/css',
            },
            innerHTML: cssContent,
          },
        ],
        postBodyTags: [
          {
            tagName: 'script',
            innerHTML: jsContent,
          },
        ],
      };
    },
  };
};
